package com.ihighest.app.infox.activity;

import org.json.JSONException;

import android.os.Bundle;
import android.webkit.WebView;
import android.widget.TextView;

import com.ihighest.app.common.api.Api;
import com.ihighest.app.common.api.ApiCallback;
import com.ihighest.app.common.api.ApiResult;
import com.ihighest.app.common.kit.AppKit;
import com.ihighest.app.infox.R;
import com.ihighest.app.infox.myview.ActivityTitle;

public class AboutActivity extends BaseActivity {

	private ActivityTitle title;
	private WebView webview;
	private TextView tv_version;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.infox_activity_about);

		title = (ActivityTitle) findViewById(R.id.id_about_title);
		title.setTitle("关于金草帽");
		title.setViewVersible(title.titleBack);
		title.setViewGone(title.titleSetting, title.titleOther, title.rightLayout, title.titleRefresh, title.titleMsg);
		inint();
		getdata();
	}

	private void inint() {
		webview = (WebView) findViewById(R.id.id_about_webview);
		tv_version = (TextView) findViewById(R.id.tv_version);

	}

	private void getdata() {
		tv_version.setText(this.getString(R.string.app_name) + " ver " + AppKit.getAppVersionName(this));
		Api.data("app_about_android.json", new ApiCallback(this) {

			@Override
			public void handleSuccess(ApiResult result) {
				// TODO Auto-generated method stub

				try {
					webview.loadData(result.getData().getString("content"), "text/html; charset=UTF-8", null);
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			}

			@Override
			public void handleFailure(Exception e, String msg) {
				// TODO Auto-generated method stub

			}
		}, this);

	}

}
